<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            display: block;
        }
    </style>
</head>
<body>
    <div class="">显示or隐藏</div>
    <button>点击</button>
    <script>
        var div = document.querySelector("div");
        var btn = document.querySelector("button");
        btn.onclick = function(){
            if(div.style.display=="none"){
                div.style.display="block";
            }else{
                div.style.display="none"
            }
        }
    </script>
</body>
</html>